﻿// 以下代码是配置layui扩展模块的目录，每个页面都需要引入
var message_pid = "-1";
var message_isstop = false;//页面是否丢失服务权
var message_isforced = false;//是否被强制拉回服务权页面,被丢失时又强制拉回权时,完全停止弱探测
layui.config({
    version: false,
    base: '/scripts/libs/module/'
}).extend({
    Cropper: 'Cropper/Cropper',
    notice: 'notice/notice',
    validform: 'validform/validform',
    DPlayer: 'DPlayer/DPlayer',
    webuploader: 'uploader/webuploader'//上传
}).use(['layer', 'lazyload', 'myaspx'], function () {
    var os = layui.myaspx;
    //图片延时加载
    $(document).find("img").lazyload({ effect: "fadeIn" });

    $("#loginout").click(function () {
        os.ajax({
            url: '/api/submit_ajax/loginout',
            data: { "time": new Date().getTime() },
            type: "get",
            dataType: 'json',
            success: function (res) {
                if (res.status != 1) {
                    return layer.msg(res.msg);
                }
                if (res.url) {
                    window.location.href = res.url;
                } else {
                    location.reload();
                }
            }
        });
    })
});
//写Cookie
function addCookie(objName, objValue, objHours) {
    var str = objName + "=" + escape(objValue);
    if (objHours > 0) {//为0时不设定过期时间，浏览器关闭时cookie自动消失
        var date = new Date();
        var ms = objHours * 3600 * 1000;
        date.setTime(date.getTime() + ms);
        str += "; expires=" + date.toGMTString();
    }
    document.cookie = str;
}

//读Cookie
function getCookie(objName) {//获取指定名称的cookie的值
    var arrStr = document.cookie.split("; ");
    for (var i = 0; i < arrStr.length; i++) {
        var temp = arrStr[i].split("=");
        if (temp[0] == objName) {
            if (temp.length == 3) {
                return unescape(temp[2]);
            }
            else {
                return unescape(temp[1]);
            }
        }
    }
    return "";
}

/*搜索查询*/
function SiteSearch(send_url, divTgs) {
    var str = $.trim($(divTgs).val());
    if (str.length > 0 && str != "输入关健字") {
        window.location.href = send_url + "?keyword=" + encodeURI($(divTgs).val());
    }
    layer.msg("请输入关健字！");
    return false;
}

//清除cookie  
function delCookie(name) {
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval = getCookie(name);
    if (cval != null) {
        document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
    }
}  